﻿using Kingdee.BOS.Core.DynamicForm.PlugIn;
using Kingdee.BOS.Core.DynamicForm.PlugIn.Args;
using Kingdee.BOS.Orm.DataEntity;
using Kingdee.BOS.ServiceHelper;
using Kingdee.BOS.Util;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Linq;
using System.Text;

namespace LiMinCRMPlugin
{
    /// <summary>
    /// 物料反审核插件
    /// </summary>
    /// <remarks>
    /// 功能：物料在反审核是清空上传MES状态
    /// 创建人：mey
    /// 创建日期：2023.5.18
    /// 修改信息（1）：修改人，修改日期，修改内容
    /// </remarks>
    /// 
    [Description("物料反审核服务")]
    [HotUpdate]
    public class MaterialUnAudit : AbstractOperationServicePlugIn
    {
        //OnPreparePropertys 数据加载前，确保需要的属性被加载
        public override void OnPreparePropertys(PreparePropertysEventArgs e)
        {
            base.OnPreparePropertys(e);
        }
        /// <summary>
        /// 事务结束后事件
        /// </summary>
        /// <param name="e"></param>
        public override void AfterExecuteOperationTransaction(AfterExecuteOperationTransaction e)
        {
            base.AfterExecuteOperationTransaction(e);
            //读取全部的单据,for循环,转换成DynamicObject类型
            foreach (DynamicObject entity in e.DataEntitys)
            {

                string FID = Convert.ToString(entity["Id"]);//物料内码                      

                string updateSql = string.Format(@"/*dialect*/ update T_BD_MATERIAL set F_DEV_FSTATUS='' 
                    where FMaterialId={0}", FID);

                DBServiceHelper.Execute(this.Context, updateSql);

            }
        }

    }
}
